<?php
namespace BP\En;
class EntityOIDName extends EntityOID {
	public function getPK () 
	{
		return "OID";
	}
	public function getPKField () 
	{
		return "OID";
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__I ($oid) // [int oid]
	{
		$me = new self();
		parent::constructor__I($oid);
		return $me;
	}
	public function getName () 
	{
		return $this->GetValStringByKey(EntityOIDNameAttr::$Name);
	}
	public function setName ($value) // [String value]
	{
		$this->SetValByKey(EntityOIDNameAttr::$Name, $value);
	}
	public function RetrieveByName () 
	{
		$qo = QueryObject::constructor__($this);
		$qo->AddWhere_String_String("Name", $this->getName());
		return $qo->DoQuery();
	}
	protected function LoadDir ($dir) // [String dir]
	{
		return 1;
	}
	protected function beforeUpdate () 
	{
		if (($this->getEnMap()->getIsAllowRepeatName() ==  FALSE ))
		{
			if (($this->getPKCount() == 1))
			{
				if (($this->ExitsValueNum("Name", $this->getName()) >= 2))
				{
					throw new \RuntimeException((((((("@更新失败[" . $this->getEnMap()->getEnDesc()) . "] OID=[") . $this->getOID()) . "]名称[") . $this->getName()) . "]重复."));
				}
			}
		}
		return parent->beforeUpdate();
	}
}
?>
